home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / MorphOS / Epic4_mos / share / epic / help / 5_programming / alias < prev    next >
Encoding:
Text File  |  2002-10-28  |  4.5 KB  |  104 lines

  1. Synopsis:
  2.    alias [[-]<alias name> [<commands>]]
  3.  
  4. Description:
  5.    ALIAS is one of ircII-EPIC's most powerful user interfaces.  It allows
  6.    the user to execute an arbitrary series of commands with one single
  7.    command.
  8.  
  9.    It actually serves a dual purpose.  The primary usage is as described,
  10.    a convenient mechanism for issuing multiple commands in succession.
  11.    It may also be used to define custom functions that can be used in
  12.    conditional or assignment statements.  The real power of aliases comes
  13.    from the fact that the client allows aliases to overload built-in
  14.    commands (but not built-in functions).
  15.  
  16.    Usage
  17.       Aliases are used just like normal commands (and functions).  They
  18.       may be called from the input line by prepending the command character
  19.       (see CMDCHARS) to them, or may be used in a script.  Likewise,
  20.       scripted functions may be called using the normal $name() notation.
  21.       Aliases have no functional differences between built-in commands and
  22.       functions.
  23.  
  24.    Syntax
  25.       Alias definitions with multiple commands may delimit the commands
  26.       with semicolons, or the commands may span multiple lines if
  27.       surrounded with curly braces.  Users familiar with C/C++ or Perl
  28.       programming will note numerous similarities in the command syntax.
  29.       Like those languages, routines and functions are distinguished by
  30.       whether the alias has a return value; functions do, routines don't.
  31.  
  32.       Aliases of both types may also accept arbitrary parameters, called
  33.       expandos.  They are used just like variables, and are numbered
  34.       sequentially, starting with 0 (zero).
  35.  
  36.    Current aliases may be displayed by only giving the alias name in the
  37.    command; all aliases matching the name are returned (such that "foo"
  38.    might return aliases "foo" and "foobar").  If no alias name is given,
  39.    all aliases are displayed.  An alias may be removed by prepending its
  40.    name with a hyphen (-).
  41.  
  42.    As mentioned previously, the client's builtin commands may be overloaded
  43.    by aliases.  This naturally poses a problem when one needs to use the
  44.    real command, and needs to be sure it isn't some alias.  The simple
  45.    answer is to use the "//command" form.  That is, the client will skip
  46.    alias expansion for any command when it is preceded by the any command
  47.    character twice.  Other methods include STACK, or avoiding command
  48.    overloading in the first place.
  49.  
  50. Examples:
  51.    To create an alias that overloads a command, and calls it too:
  52.       alias lusers {
  53.          echo ======= User Information for ${[$*] ? [$*] : S}
  54.          //lusers $*
  55.          echo ======= End User Information
  56.       }
  57.  
  58.    To create a function that returns the sum of two inputs:
  59.       alias sum {
  60.          @ function_return = [$0] + [$1]
  61.       }
  62.  
  63.    To create an alias that uses the new function:
  64.       alias showsum {
  65.          echo *** The sum of $0 and $1 is $sum($0 $1)
  66.       }
  67.  
  68.    An alternate way of definite the same alias:
  69.       alias showsum echo The sum of $0 and $1 is $sum($0 $1)
  70.  
  71.    To use the new /showsum command to compute a sum:
  72.       /showsum 4 5
  73.  
  74.    Using the alias as in the previous example will display the following:
  75.       *** The sum of 4 and 5 is 9
  76.  
  77. See Also:
  78.    assign(5); say(1); send(5); set(4) cmdchars; stack(5)
  79.  
  80. Restrictions:
  81.    As mentioned above, aliases can overload commands, but not functions.
  82.    Alias names can consist of any character that isn't already a meta
  83.    character for EPIC (the @ symbol, square brackets, curly braces, semi-
  84.    colons, parenthesis, etc.).  Note, however, that functions will not
  85.    when the name contains certain characters.  A good rule of thumb is to
  86.    limit alias names to alphanumeric characters (and the underscore).
  87.  
  88. Bugs:
  89.    The exact syntax rules for alias structures (see ASSIGN for information
  90.    about structures) is somewhat ambiguous.  Structures can be represented
  91.    as either name.sub or name[sub], but neither notation is guaranteed to
  92.    work in all instances.  Functions, for instance, do not work with the
  93.    latter.  This isn't necessarily a bug, but a feature of the syntax that
  94.    may produce some unexpected results.
  95.  
  96. Other Notes:
  97.    Like C, whitespace in scripts is generally not significant (there are
  98.    exceptions, such as with literal text to be ECHOed).  An alias can
  99.    literally be defined on one line, or on as many lines as desired.
  100.    Code indentation is not required, though is done by convention, as
  101.    with most structured languages.  Braces in multiline aliases may be
  102.    placed anywhere, as in C.
  103.  
  104.